//
//  DLViewController.m
//  duilian
//
//  Created by shaojinkuang on 7/13/16.
//  Copyright © 2016 shaojinkuang. All rights reserved.
//

#import "DLViewController.h"
#import "UIView+SDAutoLayout.h"
@interface DLViewController ()

@property (nonatomic, strong) UIImageView* leftUV;
@property (nonatomic, strong) UIImageView* rightUV;
@property (nonatomic, strong) UIImageView* topUV;
@end

@implementation DLViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor colorWithRed:23/255.0f green:44/255.0f blue:60/255.0f alpha:1.0f];
    UIButton *brn = [UIButton buttonWithType:UIButtonTypeCustom];
    brn.frame = CGRectMake(100, 100, 100, 100);
    brn.backgroundColor = [UIColor greenColor];
    [brn addTarget:self action:@selector(dismissController) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:brn];
    
    [self setupSubViews];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dismissController
{
    [self dismissViewControllerAnimated:YES completion:nil];
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark - setup subViews 
- (void)setupSubViews {
    UIImage* image = [UIImage imageNamed:@"priview-shanglian.gif"];
    CGSize uvSize = image.size;
    UIImage* topImage = [UIImage imageNamed:@"priview-hengpi.gif"];
    CGSize topSize = topImage.size;
    CGSize viewSize = self.view.size;
    
    self.leftUV = [UIImageView new];
    self.rightUV = [UIImageView new];
    self.topUV = [UIImageView new];
    
    self.leftUV.image = image;
    self.rightUV.image = image;
    self.topUV.image = image;
    
    [self.view addSubview:self.leftUV];
    [self.view addSubview:self.rightUV];
    [self.view addSubview:self.topUV];
    
    self.leftUV.sd_layout.leftSpaceToView(self.view,20).topSpaceToView(self.view,100)
    .widthIs(uvSize.width).heightIs(uvSize.height);
    
    self.rightUV.sd_layout.rightSpaceToView(self.view,20).topSpaceToView(self.view,100)
    .widthIs(uvSize.width).heightIs(uvSize.height);
    
    self.topUV.sd_layout.leftSpaceToView(self.view,viewSize.width/2 - topSize.width/2).topSpaceToView(self.view,35)
    .widthIs(topSize.width).heightIs(topSize.height);
}
@end
